import {
  HYEventStore
} from 'hy-event-store'
import {
  getranking
} from '../service/api-music'
const rankingMap = {
  0: "newRanking",
  1: "hotRanking",
  2: "originRanking",
  3: "upRanking"
}
const rankingStore = new HYEventStore({
  state: {
    newRanking: {}, //热歌榜
    hotrinking: {}, //1. 热门榜
    originRanking: {},//2.原创榜
    upRanking: {} //3.飙升榜

  },
  actions: {
    gettankings(ctx) {
      getranking(1).then(res => {
        // console.log(res)
        ctx.hotrinking = res.playlist
      })

      for (let i = 0; i < 4; i++) {
        getranking(i).then(res => {
          // console.log(i)
          // ctx.hotrinking = res.playlist
          const mapss = rankingMap[i]
          // console.log(mapss)
          ctx[mapss] = res.playlist
          // console.log(ctx[mapss])
        })
      }
    }
  }
})
export {
  rankingStore,
  rankingMap
}